/*
 * SaveMapFileFilter.java
 *
 * Created on 5 de Abril de 2007, 10:21
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.gpp.proj1.map.editor;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author Gustavo
 */
public class SaveMapFileFilter extends FileFilter {
    
    /** Creates a new instance of SaveMapFileFilter */
    public SaveMapFileFilter() {
    }
    
        public boolean accept(File f) {
        
        if (!f.exists()) {
            
            return f.getName().toLowerCase().endsWith(".map");
        }
        else {
            if (f.isDirectory()) {            
                return true;
            }
            else {
                return f.isFile() && f.canWrite() && !f.isHidden() && f.getName().toLowerCase().endsWith(".map");
            }            
        }        
    }

    public String getDescription() {
        
        return "Map file (*.map)";
    }    
}